"""
内容相关模型
"""
from datetime import datetime
from sqlalchemy import Column, Integer, String, Text, DateTime, SmallInteger, JSON
from app.db.session import Base


class Banner(Base):
    """Banner轮播图表"""
    __tablename__ = "banners"
    
    id = Column(Integer, primary_key=True, index=True, comment="主键ID")
    title = Column(String(100), comment="标题")
    subtitle = Column(String(200), comment="副标题")
    image_url = Column(String(255), nullable=False, comment="图片URL")
    link_url = Column(String(255), comment="链接地址")
    sort_order = Column(Integer, default=0, index=True, comment="排序")
    status = Column(SmallInteger, default=1, comment="状态: 1显示 0隐藏")
    created_at = Column(DateTime, default=datetime.now, comment="创建时间")
    updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment="更新时间")


class ProductCategory(Base):
    """产品分类表"""
    __tablename__ = "product_categories"
    
    id = Column(Integer, primary_key=True, index=True, comment="主键ID")
    name = Column(String(50), nullable=False, comment="分类名称")
    parent_id = Column(Integer, default=0, comment="父分类ID")
    sort_order = Column(Integer, default=0, comment="排序")
    icon = Column(String(255), comment="图标")
    created_at = Column(DateTime, default=datetime.now, comment="创建时间")
    updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment="更新时间")


class Product(Base):
    """产品表"""
    __tablename__ = "products"
    
    id = Column(Integer, primary_key=True, index=True, comment="主键ID")
    category_id = Column(Integer, index=True, comment="分类ID")
    name = Column(String(100), nullable=False, comment="产品名称")
    subtitle = Column(String(200), comment="副标题")
    cover_image = Column(String(255), comment="封面图")
    images = Column(JSON, comment="产品图片数组")
    summary = Column(Text, comment="简介")
    content = Column(Text, comment="详细内容")
    features = Column(JSON, comment="产品特性")
    specifications = Column(JSON, comment="技术参数")
    video_url = Column(String(255), comment="视频链接")
    sort_order = Column(Integer, default=0, comment="排序")
    view_count = Column(Integer, default=0, comment="浏览量")
    status = Column(SmallInteger, default=1, index=True, comment="状态: 1发布 0草稿")
    seo_title = Column(String(100), comment="SEO标题")
    seo_keywords = Column(String(200), comment="SEO关键词")
    seo_description = Column(String(300), comment="SEO描述")
    created_at = Column(DateTime, default=datetime.now, comment="创建时间")
    updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment="更新时间")


class NewsCategory(Base):
    """新闻分类表"""
    __tablename__ = "news_categories"
    
    id = Column(Integer, primary_key=True, index=True, comment="主键ID")
    name = Column(String(50), nullable=False, comment="分类名称")
    sort_order = Column(Integer, default=0, comment="排序")
    created_at = Column(DateTime, default=datetime.now, comment="创建时间")
    updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment="更新时间")


class News(Base):
    """新闻表"""
    __tablename__ = "news"
    
    id = Column(Integer, primary_key=True, index=True, comment="主键ID")
    category_id = Column(Integer, index=True, comment="分类ID")
    title = Column(String(200), nullable=False, comment="标题")
    subtitle = Column(String(300), comment="副标题")
    cover_image = Column(String(255), comment="封面图")
    summary = Column(Text, comment="摘要")
    content = Column(Text, nullable=False, comment="内容")
    author = Column(String(50), comment="作者")
    source = Column(String(100), comment="来源")
    tags = Column(String(255), comment="标签")
    view_count = Column(Integer, default=0, comment="浏览量")
    is_top = Column(SmallInteger, default=0, comment="是否置顶")
    status = Column(SmallInteger, default=1, index=True, comment="状态: 1发布 0草稿")
    publish_time = Column(DateTime, index=True, comment="发布时间")
    seo_title = Column(String(100), comment="SEO标题")
    seo_keywords = Column(String(200), comment="SEO关键词")
    seo_description = Column(String(300), comment="SEO描述")
    created_at = Column(DateTime, default=datetime.now, comment="创建时间")
    updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment="更新时间")


class Case(Base):
    """案例表"""
    __tablename__ = "cases"
    
    id = Column(Integer, primary_key=True, index=True, comment="主键ID")
    title = Column(String(200), nullable=False, comment="案例标题")
    client_name = Column(String(100), comment="客户名称")
    industry = Column(String(50), index=True, comment="所属行业")
    cover_image = Column(String(255), comment="封面图")
    images = Column(JSON, comment="案例图片")
    summary = Column(Text, comment="案例简介")
    background = Column(Text, comment="客户背景")
    challenge = Column(Text, comment="面临挑战")
    solution = Column(Text, comment="解决方案")
    result = Column(Text, comment="实施效果")
    technologies = Column(String(255), comment="使用技术")
    sort_order = Column(Integer, default=0, comment="排序")
    view_count = Column(Integer, default=0, comment="浏览量")
    status = Column(SmallInteger, default=1, index=True, comment="状态")
    created_at = Column(DateTime, default=datetime.now, comment="创建时间")
    updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment="更新时间")


class Solution(Base):
    """解决方案表"""
    __tablename__ = "solutions"
    
    id = Column(Integer, primary_key=True, index=True, comment="主键ID")
    title = Column(String(200), nullable=False, comment="方案标题")
    industry = Column(String(50), index=True, comment="所属行业")
    cover_image = Column(String(255), comment="封面图")
    summary = Column(Text, comment="方案简介")
    pain_points = Column(Text, comment="痛点分析")
    solution_content = Column(Text, comment="解决方案内容")
    architecture_image = Column(String(255), comment="架构图")
    advantages = Column(Text, comment="方案优势")
    related_cases = Column(JSON, comment="相关案例ID")
    sort_order = Column(Integer, default=0, comment="排序")
    view_count = Column(Integer, default=0, comment="浏览量")
    status = Column(SmallInteger, default=1, comment="状态")
    created_at = Column(DateTime, default=datetime.now, comment="创建时间")
    updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment="更新时间")


class Job(Base):
    """招聘职位表"""
    __tablename__ = "jobs"
    
    id = Column(Integer, primary_key=True, index=True, comment="主键ID")
    title = Column(String(100), nullable=False, comment="职位名称")
    department = Column(String(50), comment="部门")
    location = Column(String(50), index=True, comment="工作地点")
    job_type = Column(String(20), comment="工作类型: 全职/兼职/实习")
    salary_range = Column(String(50), comment="薪资范围")
    experience_required = Column(String(50), comment="经验要求")
    education_required = Column(String(50), comment="学历要求")
    description = Column(Text, comment="职位描述")
    responsibilities = Column(Text, comment="岗位职责")
    requirements = Column(Text, comment="任职要求")
    benefits = Column(Text, comment="福利待遇")
    headcount = Column(Integer, default=1, comment="招聘人数")
    status = Column(SmallInteger, default=1, index=True, comment="状态: 1招聘中 0已关闭")
    created_at = Column(DateTime, default=datetime.now, comment="创建时间")
    updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment="更新时间")


class ServicePackage(Base):
    """技术服务套餐表"""
    __tablename__ = "service_packages"
    
    id = Column(Integer, primary_key=True, index=True, comment="主键ID")
    name = Column(String(100), nullable=False, comment="套餐名称")
    subtitle = Column(String(200), comment="副标题")
    package_type = Column(String(50), comment="套餐类型")
    price = Column(String(50), comment="价格")
    original_price = Column(String(50), comment="原价")
    price_unit = Column(String(20), default="元/年", comment="价格单位")
    description = Column(Text, comment="套餐描述")
    features = Column(JSON, comment="功能特性")
    service_items = Column(JSON, comment="服务项目")
    suitable_for = Column(String(200), comment="适用对象")
    is_recommended = Column(SmallInteger, default=0, comment="是否推荐")
    sort_order = Column(Integer, default=0, comment="排序")
    status = Column(SmallInteger, default=1, index=True, comment="状态")
    created_at = Column(DateTime, default=datetime.now, comment="创建时间")
    updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment="更新时间")


class CustomPackage(Base):
    """定制开发套餐表"""
    __tablename__ = "custom_packages"
    
    id = Column(Integer, primary_key=True, index=True, comment="主键ID")
    name = Column(String(100), nullable=False, comment="套餐名称")
    subtitle = Column(String(200), comment="副标题")
    category = Column(String(50), comment="分类")
    price_range = Column(String(50), comment="价格区间")
    duration = Column(String(50), comment="开发周期")
    team_size = Column(String(50), comment="团队规模")
    description = Column(Text, comment="套餐描述")
    features = Column(JSON, comment="功能特性")
    tech_stack = Column(JSON, comment="技术栈")
    deliverables = Column(JSON, comment="交付物")
    service_process = Column(JSON, comment="服务流程")
    case_studies = Column(JSON, comment="案例研究")
    is_hot = Column(SmallInteger, default=0, comment="是否热门")
    sort_order = Column(Integer, default=0, comment="排序")
    status = Column(SmallInteger, default=1, index=True, comment="状态")
    created_at = Column(DateTime, default=datetime.now, comment="创建时间")
    updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment="更新时间")


class PackageFeature(Base):
    """套餐功能对照表"""
    __tablename__ = "package_features"
    
    id = Column(Integer, primary_key=True, index=True, comment="主键ID")
    feature_name = Column(String(100), nullable=False, comment="功能名称")
    feature_category = Column(String(50), comment="功能分类")
    description = Column(String(200), comment="功能描述")
    basic_plan = Column(String(50), comment="基础版")
    standard_plan = Column(String(50), comment="标准版")
    professional_plan = Column(String(50), comment="专业版")
    enterprise_plan = Column(String(50), comment="企业版")
    sort_order = Column(Integer, default=0, comment="排序")
    status = Column(SmallInteger, default=1, comment="状态")
    created_at = Column(DateTime, default=datetime.now, comment="创建时间")
    updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment="更新时间")


class FAQ(Base):
    """常见问题表"""
    __tablename__ = "faqs"
    
    id = Column(Integer, primary_key=True, index=True, comment="主键ID")
    category = Column(String(50), index=True, comment="问题分类")
    question = Column(String(500), nullable=False, comment="问题")
    answer = Column(Text, nullable=False, comment="答案")
    tags = Column(String(200), comment="标签")
    is_hot = Column(SmallInteger, default=0, comment="是否热门问题")
    view_count = Column(Integer, default=0, comment="浏览量")
    sort_order = Column(Integer, default=0, comment="排序")
    status = Column(SmallInteger, default=1, index=True, comment="状态")
    created_at = Column(DateTime, default=datetime.now, comment="创建时间")
    updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment="更新时间")

